 <!DOCTYPE html>
 <html lang="en">
 <head>
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <meta http-equiv="X-UA-Compatible" content="ie=edge">
     <title>Document</title>
     <style>

     </style>
 </head>
 <body>
     
 </body>
 <script>
     var Maxobj = {
      name: '3ho',
      msg: {
        age: 18
      },
      color: ['pink', 'yellow']
    }
    
    var Minobj = {} 
    function twoObj(newobj, oldobj) {
      for (k in oldobj) {
          //遍历拿到值
        let item = oldobj[k]
        if (item instanceof Array) {
          newobj[k] = []
          twoObj(newobj[k], item)
        } 
        else if (item instanceof Object) {
          newobj[k] = {}
          twoObj(newobj[k], item)
        } 
        else {
          newobj[k] = item
        }
      }
    }
    
    twoObj(Minobj, Maxobj)
    Minobj.name = 'hhh'  // hhh为改变的对象
    console.log(Minobj)
    console.log(Maxobj)
 </script>
 </html>